package com.hdoit.apollo.logical.stock.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.hdoit.apollo.logical.stock.dao.IStockCollocationDao;
import com.hdoit.apollo.logical.stock.mapper.StockCollocationMapper;
import com.hdoit.apollo.logical.stock.model.StockCollocation;
import com.tennetcn.data.dao.base.ISqlExpression;
import com.tennetcn.data.dao.base.impl.SuperDao;
import com.tennetcn.data.utils.SqlExpressionFactory;
/**
 * @author      humaoshu
 * @email       
 * @createtime  2018年04月02日 11:47:19
 * @comment
 */
@Component
public class StockCollocationDaoImpl extends SuperDao<StockCollocation> implements IStockCollocationDao{

	@Autowired
	private StockCollocationMapper stockCollocationMapper;
	
	@Override
	public List<StockCollocation> getStockCollocationByCargoId(String cargoId) {
		
		return stockCollocationMapper.getStockCollocationByCargoId(cargoId);
	}

	@Override
	public boolean deleteByStockId(String stockId) {
		ISqlExpression sqlExpression = SqlExpressionFactory.createExpression();
		sqlExpression.addBody("delete from",StockCollocation.class)
					.andWhere("stockId=#{stockId}")
					.setParam("stockId", stockId);
		return delete(sqlExpression)>=0;
	}

	@Override
	public boolean updateStockNo(String collocationId, Double num) {
		
		return stockCollocationMapper.updateStockNo(collocationId, num)>=0;
	}

	@Override
	public boolean updateStockCollocationNo(String collocationId, Double num) {
		
		return stockCollocationMapper.updateStockCollocationNo(collocationId, num)>=0;
	}

	@Override
	public StockCollocation queryModelByCollocationId(String collocationId) {
		
		return stockCollocationMapper.queryModelByCollocationId(collocationId);
	}

}